/*
 * @lc app=leetcode.cn id=1540 lang=golang
 *
 * [1540] K 次操作转变字符串
 */
package Solutions

// @lc code=start
func canConvertString(s string, t string, k int) bool {
	if len(s) != len(t) {
		return false
	}
	diff := make([]int, 0, len(s))
	for i := 0; i < len(s); i++ {
		if s[i] < t[i] {
			diff = append(diff, int(t[i]-s[i]))
		} else if s[i] > t[i] {
			diff = append(diff, int(26-s[i]+t[i]))
		}
	}
	mp := [26]int{}
	for _, v := range diff {
		mp[v]++

	}
	for key, v := range mp {
		if (v-1)*26+key > k {
			return false
		}
	}
	return true
}

// @lc code=end
